#include <cstdio>
#include "graphviewer.h"
#include <fstream>
#include <iostream>
#include <sstream>


void exercicio1()
{
	GraphViewer *gv = new GraphViewer(600, 600, true);	//! Create the graph
	gv->setBackground("background.jpg");	//! Define background image
	gv->createWindow(600, 600);		//! Create the window
	gv->defineVertexColor("blue");	//! Define color of vertexes (nodes)
	gv->defineEdgeColor("black");	//! Define color of edges
	gv->addNode(0);	//! Add node
	gv->addNode(1);	//! Add node
	gv->addEdge(0, 0, 1,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->rearrange();	//! Show graph
	Sleep(1000);		//! Wait a sec
	gv->removeNode(1);	//! Remove a node
	gv->rearrange();	//! Refresh graph
	gv->addNode(2);		//! Add node
	gv->setVertexLabel(2, "Isto e um no");		//! Add a label to a vertex (node)
	gv->addEdge(1, 0, 2, EdgeType::DIRECTED);	//! Add directed Edge
	gv->setEdgeLabel(1, "Isto e uma aresta");	//! Add label to Edge
	gv->setVertexColor(2, "green");	//! Change color of node
	gv->setEdgeColor(1, "yellow");	//! Change color of Edge
	gv->rearrange();	//! Show graph
}

void exercicio2()
{
	GraphViewer *gv = new GraphViewer(600, 600, false);	//! Create the graph
	gv->setBackground("background.jpg");	//! Define background image
	gv->createWindow(600, 600);		//! Create the window
	gv->defineVertexColor("blue");	//! Define color of vertexes (nodes)
	gv->defineEdgeColor("black");	//! Define color of edges
	gv->addNode(0, 300, 50);	//! Add node
	gv->addNode(1, 318, 58);	//! Add node
	gv->addNode(2, 325, 75);	//! Add node
	gv->addNode(3, 318, 93);	//! Add node
	gv->addNode(4, 300, 100);	//! Add node
	gv->addNode(5, 282, 93);	//! Add node
	gv->addNode(6, 275, 75);	//! Add node
	gv->addNode(7, 282, 58);	//! Add node
	gv->addNode(8, 150, 200);	//! Add node
	gv->addNode(9, 300, 200);	//! Add node
	gv->addNode(10, 450, 200);	//! Add node
	gv->addNode(11, 300, 400);	//! Add node
	gv->addNode(12, 200, 550);	//! Add node
	gv->addNode(13, 400, 550);	//! Add node
	gv->addEdge(0, 0, 1,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(1, 1, 2,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(2, 2, 3,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(3, 3, 4,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(4, 4, 5,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(5, 5, 6,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(6, 6, 7,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(7, 7, 0,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(8, 4, 9,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(9, 9, 8,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(10, 9, 10,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(11, 9, 11,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(12, 11, 12,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->addEdge(13, 11, 13,EdgeType::UNDIRECTED);	//! Add undirected Edge
	gv->rearrange();	//! Show graph
	Sleep(2000);		//! Wait a sec
	gv->removeNode(12);	//! Remove node
	gv->removeNode(13);	//! Remove node
	gv->addNode(14, 250, 550);	//! Add node
	gv->addNode(15, 350, 550);	//! Add node
	gv->rearrange();	//! Show graph
	Sleep(2000);		//! Wait a sec

}

void exercicio3()
{
}

int main() {
	//exercicio1();
	exercicio2();
	//exercicio3();
	getchar();
	return 0;
}
